package com.jasonli.dao;
import com.jasonli.domain.ProductInfo;
import org.apache.ibatis.annotations.*;
import java.util.List;
public interface ProductInfoDao {
    @Insert("insert into product_info (pid, pcontent, pname, price, pimage, pnumber, tid, pdate) " +
            "values (null, #{pcontent}, #{pname}, #{price}, #{pimage}," +
            " #{pnumber}, #{tid}, #{pdate})")
    public void save(ProductInfo info);
    @Delete("delete from product_info where pid = #{pid}")
    public void delete(Integer pid);
    @Update("update product_info set pcontent = #{pcontent}, pname = #{pname}, price = #{price} " +
            ", pimage = #{pimage}, pnumber = #{pnumber}, tid = #{tid}, pdate = #{pdate}" +
            " where pid = #{pid}")
    public void update(ProductInfo info);
    @Select("select pid, pcontent, pname, price, pimage, pnumber, tid, pdate" +
            " from product_info where pid = #{pid}")
    public ProductInfo getByPid(Integer pid);
    @Select("select pid, pcontent, pname, price, pimage, pnumber, tid, pdate" +
            " from product_info where tid = #{tid}")
    public List<ProductInfo> getByTid(Integer tid);
    @Select("select pid, pcontent, pname, price, pimage, pnumber, tid, pdate from product_info")
    public List<ProductInfo> getAll();
    //分页查询
    @Select("select * from product_info limit #{begin}, #{size }")
    List<ProductInfo> selectByPage(@Param("begin") Integer begin,@Param("size") Integer size);
    //查询总记录数
    @Select("select count(*) from product_info")
    Integer selectTotalCount();
    //分页条件查询
    List<ProductInfo> selectByPageAndCondition(@Param("begin") Integer begin,@Param("size") Integer size,@Param("info") ProductInfo info);
    //条件查询-查询总记录数
    Integer selectTotalCountByCondition(ProductInfo info);
}
